<?php
/**
 * DoctrineDemo
 * 
 * @author
 * @version 
 */
require_once 'Zend/Controller/Action.php';
class DoctrineDemoController extends Zend_Controller_Action
{
    /**
     * The default action - show the home page
     */
    public function indexAction ()
    {
    	$testEntity = new Default_Model_Test;
        $testEntity->setName('Zaphod Beeblebrox');
        $this->_em->persist($testEntity);
        $this->_em->flush();
        
        $userInfo = Zend_Auth::getInstance()->getStorage()->read();

        $this->view->username = $userInfo->user_name;
        $this->view->name = $userInfo->first_name;
        $this->view->email = $userInfo->email;
    }
    
    function init()
    {
    	$registry = Zend_Registry::getInstance();
        $this->_em = $registry->entitymanager;
        if(!Zend_Auth::getInstance()->hasIdentity())
        {
            $this->_redirect('login/index');
        }
    }
    
}
